package com.tgz.common;

import com.alibaba.fastjson.JSON;

/**
 * 
 * @ClassName: ResponseWrapperEntityUtil
 * @Description: TODO(restful返回实体对象工具)
 * @author hsj
 * @date 2018年11月5日
 *
 */
@SuppressWarnings("unused")
public final class R {
	public final static int CODE_STATUS_SUCCESS = 1;//成功
	public final static int CODE_STATUS_FAIL = 0;//失败
	public final static String EMPTY_STRING = "";//空字符串
	public final static String DEFAULT_SUCCESS_MESSAGE = "操作成功";//默认信息-成功
	public final static String DEFAULT_FAIL_MESSAGE = "操作失败";//默认信息-失败
	public final static String DEFAULT_MESSAGE = "无数据";//默认信息-无数据

	public static Object responseWithDefault(){
		return new ResponseWrapperEntity();
	}
	
	public static Object responseWithCodeStatus(int codeStatus){
		return new ResponseWrapperEntity(codeStatus);
	}
	
	public static Object responseWithMessage(String message){
		return new ResponseWrapperEntity(message);
	}
	
	public static Object responseWithData(Object data){
		return new ResponseWrapperEntity(data);
	}
	
	public static Object responseWithCodeStatusMessage(int codeStatus,String message){
		return new ResponseWrapperEntity(codeStatus,message);
	}
	
	public static Object responseWithMessageData(String message,Object data){
		return new ResponseWrapperEntity(message,data);
	}
	
	public static Object responseWithCodeStatusData(int codeStatus,Object data){
		return new ResponseWrapperEntity(codeStatus,data);
	}
	
	public static Object responseWithCodeStatusMessageData(int codeStatus, String message, Object data){
		return new ResponseWrapperEntity(codeStatus,message,data);
	}
	public static Object responseWithCodeStatusMessageDataEnhance(Object data){
		return new ResponseWrapperEntity( R.CODE_STATUS_SUCCESS, R.DEFAULT_SUCCESS_MESSAGE,data);
	}
	public static Object responseWithCodeStatusMessageDataEnhance(){
		return new ResponseWrapperEntity( R.CODE_STATUS_SUCCESS, R.DEFAULT_SUCCESS_MESSAGE,null);
	}
	
	public static Object responseWithMessageError(String message){
		return new ResponseWrapperEntity(R.CODE_STATUS_FAIL, message,null);
	}

	/**
	 * 
	* @ClassName: ResponseWrapperEntity
	* @Description: TODO(restful返回实体对象)
	* @author hsj
	* @date 2018年11月5日
	*
	 */
	private static class ResponseWrapperEntity{
		private int codeStatus = CODE_STATUS_SUCCESS;//默认restful状态码-成功
		private String message = EMPTY_STRING;//默认无数据-空
		private Object data = EMPTY_STRING;//默认无数据-空

		public int getCodeStatus() {
			return codeStatus;
		}
		public void setCodeStatus(int codeStatus) {
			this.codeStatus = codeStatus;
		}
		public String getMessage() {
			return message;
		}
		public void setMessage(String message) {
			this.message = message;
		}
		public Object getData() {
			return data;
		}
		public void setData(Object data) {
			this.data = data;
		}
		public ResponseWrapperEntity() {
			super();
		}
		public ResponseWrapperEntity(int codeStatus) {
			super();
			this.codeStatus = codeStatus;
		}	
		public ResponseWrapperEntity( String message) {
			super();
			this.message = message;
		}	
		public ResponseWrapperEntity( Object data) {
			super();
			this.data = data;
		}
		public ResponseWrapperEntity(int codeStatus, String message) {
			super();
			this.codeStatus = codeStatus;
			this.message = message;
		}
		public ResponseWrapperEntity(String message, Object data) {
			super();
			this.message = message;
			this.data = data;
		}
		public ResponseWrapperEntity(int codeStatus, Object data) {
			super();
			this.codeStatus = codeStatus;
			this.data = data;
		}
		public ResponseWrapperEntity(int codeStatus, String message, Object data) {
			super();
			this.codeStatus = codeStatus;
			this.message = message;
			this.data = data;
		}
	}
}

